package nige.d3.core;

import static org.lwjgl.opengl.GL11.glRotatef;
import static org.lwjgl.opengl.GL11.glTranslatef;

import org.lwjgl.input.Keyboard;

public class Position extends Thread {
	static float posX = 0;
	static float posY = 0;
	static float posZ = 0;
	static float yAngleRad = 0;
	static float yAngleDeg = 0;
	
	public static void keyPressed() {
		yAngleRad = (float)Math.toRadians(yAngleDeg);
		if(Keyboard.isKeyDown(Keyboard.KEY_UP)) {
			posZ += 0.001f*Math.cos(yAngleRad);
			posX -= 0.001f*Math.sin(yAngleRad);
		}
		if(Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
			posZ -= 0.001f*Math.cos(yAngleRad);
			posX += 0.001f*Math.sin(yAngleRad);
		}
		if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
			yAngleDeg -= 1f;
		}
		if(Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
			yAngleDeg += 1f;
		}
		glRotatef(yAngleDeg,0,1,0);
		glTranslatef(posX, posY, posZ);
	}
	
	@Override
	public void run() {
		while(true) {
			keyPressed();
			Utils.wait(40);
		}
	}
	
}
